{% extends "nav.html" %}
{% block little %}日志信息{% endblock %}
{% block content %}
    <!-- Main Content -->
    <div class="container-fluid">
        <div class="side-body">
            <div class="page-title">
                <span class="title">{{ little }}日志</span>
                <div class="description">{{ little }}日志查看</div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="card">
                        <div class="card-header">
                            <div class="card-title">
                                <div class="title">{{ little }}日志列表</div>
                            </div>
                        </div>
                        <div class="card-body">
                            <table class="datatable table table-striped" cellspacing="0" width="100%">
                                <thead>
                                <tr>
                                    <th>日志ID</th>
                                    <th>设备品牌</th>
                                    <th>设备型号</th>
                                    <th>设备SN</th>
                                    <th>管理IP</th>
                                    <th>日志更新时间</th>

                                </tr>
                                </thead>
                                <tfoot>
                                <tr>
                                    <th>日志ID</th>
                                    <th>设备品牌</th>
                                    <th>设备型号</th>
                                    <th>设备SN</th>
                                    <th>管理IP</th>
                                    <th>日志更新时间</th>

                                </tr>
                                </tfoot>
                                <tbody>
                                {% for i in data %}
                                    <tr>
                                        <td>{{ i.id }}</td>
                                        <td><a href="{% url "log_mess" i.id %}" target="_blank">{{ i.storage__ST_prodname }}</a></td>
                                        <td><a href="{% url "log_mess" i.id %}" target="_blank">{{ i.storage__ST_prodect }}</a></td>
                                        <td>{{ i.storage__ST_sn }}</td>
                                        <td>{{ i.storage__ST_ip }}</td>
                                        <td>{{ i.dotime}}</td>

                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                            <div>
                                {% if perms.San_port %}
                                    <button type="button" class="btn btn-primary" id="san_huitu">博科光交日志绘图数据清洗</button>
                                {% endif %}
                                {#                                  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#san_update" id="san_up">一键更新信息</button>#}
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %}
{% block js %}
    <div class="modal fade" tabindex="-1" role="dialog" id="san_update">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">更新光交信息</h4>
                </div>
                <div class="modal-body">
                    <p id="san_err">更新中,请等待&hellip;</p>
                    <div class="progress">
                        <div id="san_jindutiao" class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default st_close" data-dismiss="modal" id="ST_close">关闭</button>
                    {#                    <button type="button" class="btn btn-primary">Save changes</button>#}
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <script>
        $('#san_huitu').click(function () {
            $('#san_update').modal({backdrop: 'static', keyboard: false},'toggle')
            $("#ST_close").hide();
            $.ajax({
                url: "{% url "san_huitu_update" %}",
                type: 'GET',
                data:"",
                success: function(data){
                    var obj = JSON.parse(data);
                    if(obj.status){
                        $("#san_err").text("更新成功");
                        $("#ST_close").show();
                        $("#san_jindutiao").hide();
                    }else{
                        $("#san_err").text(obj.error);
                        $("san_jindutiao").hide();
                        $("#ST_close").show();
                    };
                }
            })
        });
    </script>
{% endblock %}